﻿
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    $(function () {
        gridList();
    })
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/OrderFlowManage/TakelookAllot/GetGridJson",
            height: $(window).height() - 96,
            colModel: [
                { label: '活动主题', name: 'F_ActivityTheme', width: 100, align: 'left', sortable: false },
                {
                    label: '带看时间', name: 'F_Source', width: 150, align: 'left', sortable: false,
                    formatter: function (cellvalue, options, rowObject) {
                        if (cellvalue) {
                            var item = JSON.parse(cellvalue);
                            return item.startTime + '~' + item.endTime;
                        }
                        return '';
                    }
                },
                { label: '城市', name: 'F_ActivityCityId', width: 300, align: 'left', sortable: false,
                    formatter: function (cellvalue, options, rowObject) {
                        var result = [];
                        $.ajax({
                            url: "/OrderFlowManage/ClientOrder/GetCitysJson",
                            data: {},
                            dataType: "json",
                            async: false,
                            success: function (citys) {
                                var arr = cellvalue.indexOf(',') == -1 ? [cellvalue] : cellvalue.split(',');
                                
                                for (var i = 0; i < citys.length; i++) {
                                    var ele = citys[i];
                                    for (var j = 0; j < arr.length; j++) {
                                        var val = arr[j];
                                        if (val == ele.Value) {
                                            result.push(ele.Text);
                                        }
                                    }
                                }
                            }
                        });
                        return result.toString();
                    } },
                { label: '场地名称', name: 'F_SiteName', width: 200, align: 'left', sortable: false },
                { label: '空间名称', name: 'F_SpaceName', width: 100, align: 'left', sortable: false },
                { label: '销售人员', name: 'F_FlowUserName', width: 100, align: 'left', sortable: false },
                { label: '带看人员', name: 'F_TakelookUserName', width: 100, align: 'left', sortable: false },
                { label: '编号', name: 'F_Id', hidden: true }
            ],
            pager: "#gridPager",
            sortname: 'F_Id desc',
            viewrecords: true
        });
    }

    function btn_add() {
        $.modalOpen({
            id: "Form",
            title: "添加带看",
            url: "/OrderFlowManage/TakelookAllot/Form",
            width: "500px",
            height: "300px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
</script>

<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <div class="btn-group">
            <a class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-eraser"></i>添加带看</a>
        </div>
    </div>
    <div class="search">
        @*<table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="请输入要查询关键字" style="width: 200px;">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>*@
    </div>
</div>

<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>